<%@page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html lang="zh-CN">
  <head>
    <base href="<%=basePath%>">
    
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <title>设计云登录</title>
	<link rel="stylesheet" href="<%=basePath%>resources/js/mybootstrap/css/bootstrap.css" />
	<link   href="<%=basePath%>resources/css/system/index/common.css" rel="stylesheet"></link>
	<link   href="<%=basePath%>resources/css/system/index/login.css" rel="stylesheet"></link>
    <script src="<%=basePath%>resources/js/dialog/jquery.js" type="text/javascript"></script>
    <script src="<%=basePath%>resources/js/jquery.cookie.js" type="text/javascript"></script>

    <script src="<%=basePath%>resources/js/form.js" type="text/javascript"></script>  
 
	<script src="<%=basePath%>resources/js/dialog/jquery.ui.draggable.js" type="text/javascript"></script>
	<script src="<%=basePath%>resources/js/dialog/jquery.alerts.js" type="text/javascript"></script>
	<link  href="<%=basePath%>resources/js/dialog/jquery.alerts.css" media=screen  type=text/css rel=stylesheet>
	<script src="<%=basePath%>resources/js/system/index/copyright.js" type="text/javascript"></script>
	<script src="<%=basePath%>resources/js/system/index/Cookies.js" type="text/javascript"></script>
    <script type="text/javascript">
     
       var CONTEXT_PATH = '<%=basePath %>';
       
    </script>

     
  </head>
  
  <body class="indexBody">
 
  	<div class="indexBox">
  		<form class="indexForm loginForm" id="loginForm">
  			<div class="index-title">登录页面</div>
			<div class="list-box">
				<div class="list-tr">
					<input type="text" name="phone" id="phone" placeholder="用户名/手机号" />
				</div>
				<div class="list-tr">
					<input type="password" name="password" id="password" placeholder="密码" />
				</div>
			</div>
			<div class="handle-bar">
				<div class="rememberPass"><input id="isremember" name="" type="checkbox" value="" checked=""> 记住我</div>
				<a class="forgetPass" href="<%=basePath%>before/forgetPass">忘记密码</a>
			</div>
			
			<div class="foot-box btn1" id="loginSure">
				<a class="foot-butten a-white" href="javascript:;">登录</a>
			</div>
			
			<div class="error-resgister">
				<span id="errorContent"></span><!-- 错误提示 -->
			</div>
			
			<div class="bottom-bar">
				<div class="bottom-line"></div>
				<a class="bottom-btn" href="<%=basePath%>before/register">立即注册</a>
			</div>
  		</form>
  		
  		<div id="copyrightPageBox"></div>
  	</div>
  	
  	

 
  	
  	<script type="text/javascript">
		    $(document).ready(function(){
		    	if ($.cookie("rmbUser") == "true") {
    				$("#isremember").attr("checked", true);
    				$("#phone").val($.cookie("username"));
    				$("#password").val($.cookie("password"));
    			}
				loginSure();
			});
			
			function loginSure(){
				$("#loginSure").click(function(){
					var phone=$("#phone").val();
					var password=$("#password").val();
					
					if ($("#isremember").attr("checked")) {
      					var str_username = $("#phone").val();
      					var str_password = $("#password").val();
      					$.cookie("rmbUser", "true", { expires: 7 }); //存储一个带7天期限的cookie
      					$.cookie("username", str_username, { expires: 7 });
      					$.cookie("password", str_password, { expires: 7 });
    				}else {
      					$.cookie("rmbUser", "false", { expire: -1 });
      					$.cookie("username", "", { expires: -1 });
      					$.cookie("password", "", { expires: -1 });
    				}
					
					if(phone=="" || password==""){
					
						$(".error-resgister").css("display","block");
						$("#errorContent").text("您所填信息不完整！");
					
					}else{
					
						$("#errorContent").text("");
						$("#loginSure a").text("登录中...");
						$.ajax({
							 type: 'post',
						     url: '<%=basePath%>before/login', 
							 data:  $("#loginForm").serialize(),
							 dataType: 'json',
							 success: function(data) {  
				                if(data.result){
				                	$("#loginSure a").text("登录");
				                	$(this).resetForm(); // 提交后重置表单 
				                	if(data.obj.admin){
				                    	window.location.href='<%=basePath%>after/user/user_list';
				                	}else{
				                	    window.location.href='<%=basePath%>front/carDesign/carDesign_list';
				                	}
				             
				                }else{
				                	jAlert(data.msg,'提示');
				                	$("#loginSure a").text("登录");
 			                    }

				            }
							
						});
 
					 }
		 
		       });
			
			}
	</script>
    
  </body>
</html>
